package org.mili.ticketeer.dto;

import org.mili.application.dto.Archivable;
import org.mili.application.dto.Field;
import org.mili.application.dto.Identifieable;

import java.sql.Timestamp;
import java.util.HashMap;
import java.util.Map;

public class Meeting extends Identifieable implements Archivable {

    public static enum Fields implements Field {
        DATE;
    }

    public static final String TABLE = "meeting";

    private Timestamp date;

    @Override
    public Map<Field, Object> valueMap() {
        Map<Field, Object> map = super.valueMap();
        map.put(Fields.DATE, date);
        return map;
    }

    @Override
    public Map<Field, Object> valueMapWithoutId() {
        Map<Field, Object> map = new HashMap<>(valueMap());
        map.remove(Identifieable.Fields.ID);
        return map;
    }

    @Override
    public Map<Field, Object> getUniqueFields() {
        Map<Field, Object> map = new HashMap<>();
        map.put(Fields.DATE, date);
        return map;
    }

    public Timestamp getDate() {
        return date;
    }

    public void setDate(Timestamp date) {
        this.date = date;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Meeting meeting = (Meeting) o;

        if (date != null ? !date.equals(meeting.date) : meeting.date != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return date != null ? date.hashCode() : 0;
    }

    @Override
    public String toString() {
        return "Meeting{" +
                "date=" + date +
                '}';
    }
}
